﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace NhanAi.Public
{
    public partial class PublicPagingBar : System.Web.UI.UserControl
    {
        #region fields
        int pageNumber;
        int pageSize;
        int totalItemCount;
        string searchString;     

        #endregion

        public int PageNumber { get { return pageNumber == 0 ? 1 : pageNumber; } set { pageNumber = value; } }
        public int PageSize { get { return pageSize; } set { pageSize = value; } }
        public int PageCount
        {
            get
            {
                int a = totalItemCount % pageSize;
                return a == 0 ? totalItemCount / pageSize : totalItemCount / pageSize + 1;
            }
        }
        public int TotalItemCount { get { return totalItemCount; } set { totalItemCount = value; } }
        public bool HasNextPage { get { return PageNumber < PageCount && PageNumber >= 1; } }
        public bool HasPreviousPage { get { return PageNumber > 1 && PageNumber <= PageCount; } }
        public string SearchString { get { return searchString; } set { searchString = value; } }
        
        protected void Page_Load(object sender, EventArgs e)
        {
            DataBind();
        }
    }
}